Skip to content

Pull requests overview: every signal recorded at the source, trends from history, and the opt-in digest and nudges - #995

Open
nambok wants to merge 3 commits into
mainfrom
prs-overview-signals
Open

nambok wants to merge 3 commits into
mainfrom
prs-overview-signals

Conversation

@nambok

@nambok nambok commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

This replaces #991, which GitHub closed when #985 merged and deleted its base branch. It's the same work, now on main. The org overview no longer says "not recorded yet". Each signal is now recorded where it happens, for every pull request and repository, whoever wrote it. The weekly digest and per-pull-request nudges exist too, and both are off until a team turns them on.

Changes

  • Main red time, and pull requests blocked by a red main (common::pr_ci): every check_run, status and workflow_job webhook on the default branch updates one record per repository. The record holds the head's checks and the red episodes, each with its start, its end and the commit that fixed it. A pull request is blocked by main when a check failing on it is failing on main now.
  • Runner queue p95: each job's started_at minus created_at, from workflow_job (newly routed to the overview) and from check runs.
  • Findings funnel and verified-fixed rate (common::pr_findings): the reviewer writes it each time it stores a review. Findings go raised, then acknowledged, then changed, then verified, or else dismissed. A finding counts as verified only when the reviewer finds it gone at a later head; resolving the thread isn't enough.
  • Run end states (common::pr_runs): each run maps to one of first_try, after_fixes, rerun_only, gave_up, blocked or stopped, using the ending the run's end gate recorded. The state goes on History as run_outcome, with stop_reason, when the pull request closes. A nightly reconcile covers runs that end after the pull request closed. A test walks every run status and every ending kind and reason, and checks each maps to exactly one state.
  • Cost per merged pull request: the runs' recorded cost_usd, summed onto History as cost_micro_usd.
  • Single-reviewer paths and sensitive-path merges: History now keeps the pull request's files, up to 300.
  • Sensitive paths per repo (common::pr_settings, GET/PUT /api/prs/settings; changing them needs agent settings): the defaults are **/auth/**, **/payments/**, **/secrets/**, **/infra/** and **/migrations/**. For example, acme/checkout can list cart/rounding/** and *.pem instead. The SLA days are saved here as well.
  • Security alerts with no pull request: open Dependabot findings that no pull request addresses yet, read from the security findings CoderHelm already keeps. Code scanning says it needs the security events permission.
  • Trends from history (common::pr_trends): no snapshots needed, so they show on the first day after the backfill.
    • Every merged PR's cycle time over 90 days, one point each.
    • Open PRs per stage per day over 12 weeks, rebuilt from each PR's opened and closed times and its stage change log. Days the log doesn't reach count in the total only, and split_from says from which day the split is complete.
    • When no snapshot is a week old, the strip's week-over-week change and its 8-week sparkline come from the same flow, and the review flow comes from the request and review logs.
    • "Not enough history yet" is now kept for data CoderHelm records going forward, and says which. Numbers that are recorded but have too few events say "too few yet" (reason few).
  • Shared reader: the overview read moves into common::pr_overview_read, so the page and the digest read it the same way.
  • Digest and nudges (worker::passes::pr_notify, run on the 20-minute tick):
    • The digest goes Monday from 13:00 UTC, once a week. It goes to the team's Slack or Teams update channels, or by email to listed addresses that belong to team members.
    • Nudges are private emails to the person whose turn it is. They go at the stage's p85, then two and four working days later, then never again for that stage. A pull request with a person's activity in the last working day is skipped.
  • Incident case ya_overview_signals_recorded: pins the recording points, the six end states, the permission wording and the opt-in defaults. xz follows the reader to common.
  • Docs: docs/pull-requests/api_contract.md covers the new records.

Verification

  • cargo fmt --all --check, rustfmt --check on the incidents, and cargo clippy -p common -p worker -p gateway --all-targets -D warnings are clean.
  • The full cargo test -p common -p worker -p gateway passes.
  • text_guard.py, domain_examples.py and brand_spelling.py pass.
  • New unit tests cover the trends (open per stage from the change log, unknown before it, one cycle point per merge), main CI episodes and blocked-by-main, the findings funnel, every run ending, sensitive-path globs and validation, nudge timing (three a stage, weekends skipped, none while moving), and the digest's content.

The dashboard side is CoderHelm/coderhelm#548 (settings, merged) and CoderHelm/coderhelm#549 (the overview design and the trend charts).

…t-in digest and nudges

The overview no longer says "not recorded yet". Each signal is recorded
where it happens, for every pull request and repository:

- default-branch check runs, statuses and job waits from the webhook,
  into one record per repository with red episodes and runner waits
  (common::pr_ci); pull requests blocked by a red main
- CoderHelm's findings, each time the reviewer stores a review, from
  raised to verified fixed at a later head (common::pr_findings)
- every run's end state, stop reason and cost on the pull request's
  history, at close and nightly (common::pr_runs), with a test that every
  ending maps to exactly one of six states
- closed pull requests' files, for single-reviewer paths and
  sensitive-path merges against each repository's list, defaulting to
  auth, payments, secrets, infra and migrations (common::pr_settings,
  GET/PUT /api/prs/settings)
- open Dependabot alerts with no pull request; code scanning says it
  needs the security events permission

The overview read moves into common::pr_overview_read so the page and the
weekly digest share it. The digest (Monday, to the team's channels or its
members by email) and private nudges (at the stage's p85, then two and
four working days later, then never) are both off until a team turns
them on. Incident case ya_overview_signals_recorded pins it.
…ot snapshots

The overview answers what the backfilled history can answer, from the
first day after the backfill: every merged pull request's cycle time over
90 days, and open pull requests per stage per day over 12 weeks, rebuilt
from each one's opened and closed times and its stage change log (days the
log doesn't reach count in the total, and split_from says where the split
is complete). With no snapshot a week old, the strip's change and its 8
weeks, and the review flow, come from the same history. "Not enough
history yet" is kept for what CoderHelm records going forward; a recorded
number with too few events says "too few yet" (reason "few").
@nambok nambok added the ch-review CoderHelm reviews this pull request label Dec 6, 2026
coderhelm[bot]

This comment was marked as outdated.

…nd reruns

- A red main episode closes only when the fixing head's check suites have
  completed, not when the checks reported so far are done; check_suite
  events reach the record, and a test holds an episode open while a suite
  is still running.
- Runner queue samples come only from workflow_job, from the job's own
  queued time to its start, one per job id; check runs add none.
- ci_flaky is read as the boolean it is stored as, so a run that went
  green only after a rerun counts as rerun_only; a test covers it.
- A thread moves the finding its whole title names, the longest first.
- Cost per merged PR averages only the PRs whose cost was recorded.
- Single reviewer paths and sensitive paths say "history" until file
  lists are recorded, instead of reading as zero.
- A glob with no slash matches the name at any depth, and a wildcard
  matches to the end of the name.
- The digest and nudges free their claim when nothing was sent, and a
  failed nudge state write is logged.
- A reopened pull request counts as open in the trends, not by its
  earlier history row.
- One helper builds the per pull request sort keys.

@coderhelm coderhelm Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested: 1 required item (a required rule, a failing check or an unproven critical path).

Holding the merge:

  • services/worker/src/passes/pr_records.rs:139 A failed run read still settles the row with partial cost and outcome (a critical-path change with no test or proof)

Why changes requested: services/worker/src/passes/pr_records.rs:139 A failed run read still settles the row with partial cost and outcome (a critical-path change with no test or proof).

Details: PR Overview · 🎯 Risk · Also worth a look · Earlier comments

PR Overview

The PR records the pull request overview signals at their source (main CI, findings, run end states, cost, files).

Changes

  • New common modules: pr_ci, pr_findings, pr_runs, pr_settings, pr_trends, pr_notify and pr_overview_read
  • Webhook recording of check_run, status and workflow_job events into per-repository main CI records
  • Findings funnel written by the reviewer, and run end states stored on History
  • GET and PUT /api/prs/settings for sensitive paths and SLA days
  • A worker pass for the digest and nudges, both off by default
  • An incident case and API contract docs
  • New per-repo default-branch CI record (common::pr_ci) fed by check_run, check_suite, status and workflow_job webhooks: red episodes, blocked-by-main, runner queue samples
  • Findings funnel, run end states and cost are recorded when a review is stored, with a nightly reconcile for runs that end after close

Reviewed Changes

25 changed files.

Show a summary per file
File Description
docs/incidents/ya_overview_signals_recorded.md Incident write-up for the overview signals now recorded at the source, with the guarantee they pin.
docs/pull-requests/api_contract.md Documents the new history fields, the records written at the source, the settings, and the digest and nudge behaviour.
services/common/src/lib.rs Declares the new pr_ci, pr_findings, pr_notify, pr_overview_read, pr_runs, pr_settings and pr_trends modules.
services/common/src/pr_ci.rs New default-branch CI record: rollup of checks and suites, red episodes, queue samples, blocked_by_main, and a versioned DynamoDB…
services/common/src/pr_findings.rs New per-PR findings record: raise, acknowledge, change, verify and dismiss transitions, a funnel over a time window, and a versioned…
services/common/src/pr_history.rs Adds files (capped at 300) and cost_micro_usd to History, filled when a row is built from a record. The struct is…
services/common/src/pr_notify.rs Pure digest builder (text and card), digest timing (Monday from 13:00 UTC), working-day arithmetic, nudge schedule (3 per stage) and…
services/common/src/pr_overview.rs Adds the new Input fields (main_ci, findings, settings, alerts) and computes main red time, blocked-by-main, the funnel, cost per merged…
services/common/src/pr_overview_read.rs New shared reader: team records with runs and reviewer joined, history, snapshots, backfill, main CI, findings, settings and open…
services/common/src/pr_runs.rs Maps one run's recorded status, ending, CI rounds and cost to one of six end states and a stop reason. Picks the last ended run and sums…
services/common/src/pr_settings.rs New settings document: default and per-repository sensitive-path globs, SLA days, digest and nudge opt-ins, validation and DynamoDB…
services/common/src/pr_trends.rs Pure functions that rebuild open-per-stage per day and one cycle point per merged PR from History, spans and open records, with unit tests.
services/gateway/src/main.rs Registers GET and PUT /prs/settings.
services/gateway/src/permissions.rs Adds prs_overview::get_settings to the read capability and prs_overview::put_settings to the settings-write capability.
services/gateway/src/routes/github_webhook.rs Adds workflow_job to the events passed to the pull request recorder.
services/gateway/src/routes/prs.rs The webhook writer now also updates the default-branch CI record; History gets its run end state and cost from pr_runs; the run and…
services/gateway/src/routes/prs_overview.rs The overview handler delegates to the shared reader; adds the get_settings and put_settings handlers.
services/worker/src/main.rs Runs the digest and nudge sweeps on the 20-minute tick and logs the counts.
services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs The team-key assertion now checks the shared reader's run join.
services/worker/src/passes/incidents/xz_org_overview_facts_only.rs Input gets the new fields; the per-read team-keying checks now target pr_overview_read.rs.
services/worker/src/passes/incidents/ya_overview_signals_recorded.rs Incident case with behaviour tests and source assertions for the recording points, the six run end states, the permission wording, the…
services/worker/src/passes/mod.rs Declares the new pr_notify pass module.
services/worker/src/passes/pr_notify.rs New sweeps: a Monday digest to Slack, Teams or members' email, and private per-pull-request nudge emails. Each step is claimed once and…
services/worker/src/passes/pr_records.rs Nightly reconcile_runs: sets run outcome, stop reason and cost on closed History rows whose runs ended after close.
services/worker/src/passes/review_pr.rs After storing a review, records raised findings and the earlier threads' judged status into the findings funnel.

This part only changes services/common/src/lib.rs, which adds seven pub mod declarations. I listed services/common/src and every declared module has its file. Nothing in the declarations breaks anything. The logic sits in the other parts of the review.

🎯 Risk: HIGH (77/100)

  • ██████████ blast radius 100 — ~185 dependent refs; hottest: lib.rs (~25), main.rs (~25), permissions.rs (~25)
  • ███░░░░░░░ sensitive area 30 — sensitive-adjacent additions
  • ████████░░ test coverage 80 — 25 source / 0 test file(s) changed
  • ██████████ size/spread 94 — 4514 lines across 25 file(s), spread 79%

Also worth a look

On code that hasn't changed since my previous review, which missed them. They are notes, not part of the verdict:

  • services/common/src/pr_ci.rs:484 One hot record per repo, 4 retries with no backoff: busy repos can drop CI events
  • services/common/src/pr_findings.rs:143 A finding can be counted as both dismissed and verified

Earlier comments

8 settled and resolved · 0 still open


Was this review right? Rate it 👍 / 👎 so the reviewer learns · reply @coderhelm re-review or @coderhelm <question>

facts.push(common::pr_runs::facts_of(item));
}
}
Err(e) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking (critical path, no proof): A failed run read still settles the row with partial cost and outcome (correctness)

In reconcile_runs, a get_item error only logs a warning and the run is left out of facts. A run whose item isn't found is left out the same way. The is_over guard then runs only over the runs that were read, so the row proceeds. of_runs sums cost over the remaining runs and picks the last ended one, and the row is written with a non-empty run_outcome. The filter h.run_outcome.is_empty() never selects the row again. One transient DynamoDB error therefore stores an under-counted cost_micro_usd and possibly the wrong end state for good. The same happens when run_ids has more than 10 entries, since only the first 10 are read.

/// Nudges per stage: at p85, two working days later, four working days later.
pub const NUDGES_PER_STAGE: u8 = 3;

pub fn nudge_sk(repo: &str, number: u64) -> String {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Blocking (correctness): Near-identical helpers added together (scope)

services/common/src/pr_notify.rs adds nudge_sk next to findings_sk (in services/common/src/pr_findings.rs), added in the same change. Keep one helper with the shared logic (a parameter for what differs) and call it from both places. If the ticket truly needs it, say why on a line Wider than the ticket: services/common/src/pr_notify.rs: <why>.

}

#[test]
fn a_signal_without_its_permission_says_which() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Blocking (correctness): Near-identical helpers added together (scope)

services/worker/src/passes/incidents/ya_overview_signals_recorded.rs adds a_signal_without_its_permission_says_which next to every_review_records_its_findings_and_moves_the_earlier_ones_on, added in the same change. Keep one helper with the shared logic (a parameter for what differs) and call it from both places. If the ticket truly needs it, say why on a line Wider than the ticket: services/worker/src/passes/incidents/ya_overview_signals_recorded.rs: <why>.

}

/// A suite seen on the head: pending until it completes.
fn note_suite(&mut self, id: &str, completed: bool) -> bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 FYI: Can a suite that never completes keep a red episode open? (question)

A head is only green when every suite seen on it has completed. check_suite events from an app that registers a suite on each push but never creates a run could leave a suite at queued forever. That would stop the episode from ever closing on that head. Whether such suites reach this app's webhook depends on GitHub's delivery behaviour and the repos' installed apps, which I can't check from here. Worth confirming against a real check_suite delivery stream for a repo with several apps. If they do arrive, consider counting only suites that have at least one check run.

.and_then(|r| r.split('/').next())
.map(str::to_string)
.or(org.map(str::to_string))
.or_else(|| open.first().map(|o| o.rec.org().to_string()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 Suggestion: Digest with no scope reports one arbitrary org (correctness)

When neither org nor repo is given, the scope falls back to the org of the first open record. The worker digest calls read(&t, &team, None, None, ...), so a team with pull requests in more than one org gets a digest for only the org whose record sorts first. The dashboard page lets the user pick an org, but the digest has no equivalent. I didn't confirm whether multi-org teams exist in practice. If they do, the digest should say which org it covers, or send one per org.

This blocks: Shows the digest's main path picks one arbitrary org for multi-org teams, defeating the PR's stated digest goal with the code path given

"check_run" | "check_suite" | "status" | "workflow_job"
) {
let t = now();
if let Err(e) = common::pr_ci::update(&state.dynamo, table, team_id, repo, |m| {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 Suggestion: Every check event on any branch costs one consistent read (perf, not verified)

pr_ci::update does a consistent get_item before it calls apply_event. apply_event returns false for any check or status event off the default branch, which is most of them (PR heads). So every check_run, check_suite, status and workflow_job webhook now costs one consistent DynamoDB read inline in the handler, and no write is made for the off-default ones. Skipping the call when the event's branch isn't the default branch, or when the payload carries no default branch, would avoid the read. I could not measure the webhook volume from here, so this is a note.

@coderhelm
coderhelm Bot dismissed their stale review December 6, 2026 07:16

Superseded by CoderHelm's latest review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ch-review CoderHelm reviews this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant